const express = require('express');
let router = new express.Router();
const messageDAO = require('../dao/messageDAO');

router.get('/message',(req,res)=>{
  let promise=messageDAO.select()
  promise.then((data)=>{
    res.json({
      data:data
    });
  },(err)=>{
    console.log("err:"+err);
  })
})


router.get('/query',(req,res)=>{
  let query={};
  query.m_username=req.query.username;
  query.m_title=req.query.title;
  let promise=messageDAO.query(query)
  promise.then((date)=>{
    res.json({
      data:date
    });
  },(err)=>{
    console.log("err:"+err);
  })
})


module.exports=router;
